<template>
  <!-- 已登录 -->
  <div v-if="userStore.isLogin" class="sidebarMoney">
    <div>
      <div class="user">
        <NuxtImg src="/images/user/headsculpture_img_0.png" class="userImg" />
        <div class="user_m">
          <p>{{ userName }}</p>
          <NuxtImg src="/images/user/vipSignIn_0.png" class="vipImg" />
          <div class="b_box">
            <div>ID：{{ userId }}</div>
            <NuxtImg
              src="/images/layout/icon-copy.png"
              @click="copyText(userId)"
              v-click-move
            />
          </div>
        </div>
      </div>
      <div class="btnBox">
        <div class="btn1" v-click-move @click="toCarteira(1)">
          <NuxtImg src="/images/user/pig.png" />
          <p>{{ userLang.deposit_btn }}</p>
        </div>
        <div class="btn2" v-click-move @click="toCarteira(2)">
          <NuxtImg src="/images/user/wallet.png" />
          <p>{{ userLang.withdraw_btn }}</p>
        </div>
      </div>
    </div>
  </div>
  <!-- 未登录 -->
  <div v-else class="sidebarMoney">
    <div class="notLoggedIn">
      <div class="btn heat_btn" v-click-move @click="openLogin">
        {{ systemLang.entrar }}
      </div>
      <div class="btn heat_btn" v-click-move @click="openRegister">
        {{ systemLang.registrar }}
        <div class="icon">
          <NuxtImg src="/images/home/head/register_gift.png" />
          <span>{{ systemLang.bonus_title }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const [userLang, systemLang]: any = await Promise.all([
  getCurrentPageLang("user"),
  getCurrentPageLang("system"),
]);

const emits = defineEmits(["close"]);

const userName = ref("ardzb");
const userId = ref("4031730");

const userStore = useUserStore();

function openLogin() {
  userStore.changeShowLogin(true, 1);
}
function openRegister() {
  userStore.changeShowLogin(true, 2);
}

function toCarteira(type: number) {
  emits("close");
  userStore.changeShowCarteira(true, type);
}
</script>

<style scoped lang="scss">
.sidebarMoney {
  width: 7.3rem;
  padding: 0.32rem;
  border-radius: 0.3rem;
  background: var(--box-bg-color);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0.2rem;
  margin-bottom: 0.3rem;
  color: var(--theme-neutral1);
}
.sidebarMoney .user {
  display: flex;
  align-items: center;
  width: calc(100% - 0.3rem);
  margin-bottom: 0.32rem;
  position: relative;
  z-index: 2;
}
.sidebarMoney .user .userImg {
  width: 1.2rem;
  height: 1.2rem;
}
.sidebarMoney .user_m {
  display: flex;
  flex-direction: column;
  margin-left: 0.27rem;
  font-size: 0.4rem;
  color: var(--theme-neutral1);
}
.sidebarMoney .user_m p {
  font-size: var(--font-title2);
  display: flex;
  align-items: center;
  font-weight: 100;
}
.sidebarMoney .user_m .vipImg {
  width: 0.8rem;
  object-fit: contain;
  position: absolute;
  right: 0.45rem;
}
.sidebarMoney .user_m .b_box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-title2);
  gap: 0.1rem;
  position: relative;
  z-index: 1;
  margin-top: 0.2rem;
}
.sidebarMoney .user_m .b_box div {
  font-weight: 100;
}
.sidebarMoney .user_m .b_box img {
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.1rem;
}
.sidebarMoney .btnBox {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.13rem;
  position: relative;
  z-index: 2;
}
.sidebarMoney .btnBox .btn1 {
  background-color: #ff69b4;
}
.sidebarMoney .btnBox div {
  width: 3.2rem;
  height: 1.2rem;
  border-radius: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.23rem;
  font-size: 0.44rem;
  font-weight: 700;
  color: var(--theme-neutral1);
}
.sidebarMoney .btnBox div img {
  height: 0.5rem;
}
.sidebarMoney .btnBox .btn2 {
  background-color: #ffd60c;
  color: #9b5b00;
}
.notLoggedIn {
  display: flex;
  gap: 0.2rem;
  padding-right: 0;
  align-items: center;
}
.notLoggedIn .btn {
  width: 2rem;
  height: 0.8rem;
  font-size: 0.34rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-neutral1);
  border-radius: 0.2rem;
  position: relative;
}
.sidebarMoney .notLoggedIn .btn {
  width: 3.2rem;
  height: 1.2rem;
  font-size: 0.44rem;
  font-weight: 700;
}
.notLoggedIn .btn:first-child {
  background-color: #ff69b4;
}
.notLoggedIn .btn:last-child {
  background-color: #ffd60c;
  color: #3b1d33;
}
@keyframes move-a5f7dbf4 {
  0% {
    transform: rotate(-10deg) scale(0.8);
  }
  25% {
    transform: rotate(10deg) scale(0.8);
  }
  50% {
    transform: rotate(0) scale(0.8);
  }
  70% {
    transform: rotate(0) scale3d(0.8, 0.9, 0.8);
  }
  90% {
    transform: rotate(0) scale3d(0.8, 0.9, 0.8);
  }
  100% {
    transform: rotate(-10deg) scale(0.8);
  }
}
.icon {
  width: 1rem;
  position: absolute;
  top: -0.16rem;
  right: -0.19rem;
  z-index: 5;
  animation: move-a5f7dbf4 3s linear infinite;
  img {
    width: 100%;
    height: 100%;
    vertical-align: middle;
  }
  span {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.24rem;
    color: #fff;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
@keyframes move-a {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(0.15rem);
  }
  100% {
    transform: translateY(0);
  }
}
.move {
  animation: move-a 0.5s ease-out;
}
</style>
